﻿#pragma once

#include <string>

#include <fast_io/fast_io.h>
#include <fast_io/fast_io_device.h>
#include <fast_io/fast_io_dsal/vector.h>

#include <json/nlohmannjson.h>

class ConfigManager {
public:
	std::u8string currentConfig{};  // not default...
	static fast_io::dir_file configDirectory;

private:
	nlohmann::json SettingObj;

public:
	ConfigManager() = default;
	~ConfigManager() = default;

	bool loadConfig(std::u8string_view name, fast_io::nt_fs_dirent* nfl = nullptr);
	bool loadConfigFromClipBoard();
	bool createConfig(std::u8string_view name);
	bool deleteConfig(std::u8string_view name);
	bool saveConfig();
	static fast_io::vector<std::u8string> list();

	static constexpr bool nameCheck(std::u8string_view name) {
		return !name.empty() && 
			   name.find(u8' ') == std::u8string_view::npos &&
			   name.find(u8'.') == std::u8string_view::npos &&
			   name.find(u8'/') == std::u8string_view::npos &&
			   name.find(u8'\\') == std::u8string_view::npos;
	}
	// void init() ;
};

extern ConfigManager configMgr;